package com.jz.cash.client.service.impl;

import com.jz.cash.client.entity.CountCharteredConfig;
import com.jz.cash.client.service.CountCharteredConfigService;
import com.jz.cash.client.states.DeleteState;
import com.stip.mybatis.generator.plugin.BaseExample;
import com.stip.mybatis.generator.plugin.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class CountCharteredConfigServiceImpl extends BaseService<CountCharteredConfig, BaseExample, Long> implements CountCharteredConfigService {
    @Override
    public CountCharteredConfig getRoleByMerchantId(Long merchantId) {

        BaseExample example = new BaseExample();
        example.createCriteria().addCriterion("merchant_id=", merchantId).addCriterion("mark_for_delete=", DeleteState.TRUE.getState());

        List<CountCharteredConfig> countCharteredConfigs = selectByExample(example);

        if (!CollectionUtils.isEmpty(countCharteredConfigs)) {
            return countCharteredConfigs.get(0);
        }
        return null;
    }
}